package com.xinfan.io.inputstream;





import com.xinfan.io.Dog;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;

/**
 * @Author xin
 * @Date 2022/6/8 22:26
 * @Version 1.0
 */
public class ObjectInputStream_ {
    public static void main(String[] args) throws IOException {

        String src = "G:\\桌面\\test.dat";

        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(src));

        System.out.println(ois.readInt());
        System.out.println(ois.readDouble());
        System.out.println(ois.readChar());
        System.out.println(ois.readUTF());
        try {
            Object object = ois.readObject();//存取顺序一定要一致否则有可能出现抓换异常
            Dog dog = (Dog)object;
            System.out.println(dog);
            //System.out.println();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

      ois.close();


    }
}





